/**
 * @param {string} s
 * @return {character}
 */
var firstUniqChar = function(s) {
  if(!s) return " ";
  let map = new Map(), show = 0;
  for(let i = 0; i < s.length; i++) {
    if(map.has(s[i])) {
      map.get(s[i]).count++;
    } else {
      map.set(s[i], {
        count: 1,
        show,
        alpha: s[i]
      });
      show++;
    }
  }
  let arr = [...map.values()];
  arr.sort((a, b) => a.show - b.show);
  for(let i = 0; i < arr.length; i++) {
    if(arr[i].count == 1) return arr[i].alpha;
  }
  return " ";
};
let s = "abaccdeff";
console.log(firstUniqChar(s));
s = "";
console.log(firstUniqChar(s));
